package cn.chengpengper.fragmentUpload.common;

/*@formatter:off*/

/**
 * ____________________
 * < 神兽护体，永无bug! >
 * --------------------
 *
 * @author catwing
 * @version v1.0.0
 * @date 2024/12/4 22:44
 * @description 公共响应体工具类
 */

/*@formatter:on*/

public class ResultUtils {
    public static final String SUCCESS = "1";
    public static final String ERROR = "0";

    public static <T> Result<T> ok() {
        return result(SUCCESS, null, null);
    }

    public static <T> Result<T> ok(T data) {
        return result(SUCCESS, data, null);
    }

    public static <T> Result<T> error(String msg) {
        return result(ERROR, null, msg);
    }

    public static <T> Result<T> result(String code, T data, String msg) {
        Result<T> r = new Result<>();
        r.setCode(code);
        r.setData(data);
        r.setMsg(msg);
        return r;
    }
}
